+2000-10-02 Havoc Pennington <hp@pobox.com>
+
+ * gtk/gtktextview.c: text_window_* weren't static and should have
+ been.
+ Start work on child widgets; not yet complete, syncing to
+ office computer.
+
+ * gtk/gtktextchild.h: change this to contain a public interface,
+ starting work on child interfaces.
+ * gtk/gtktextchildprivate.h: move private interfaces here
+
+ * gtk/Makefile.am: update to reflect gtktextchildprivate.h
+
+ * gtk/gtktextview.h, gtk/gtktextview.c, gtk/gtktextbuffer.h,
+ gtk/gtktextbuffer.c, gtk/gtktextiter.h, gtk/gtk/textiter.c,
+ gtk/gtktextmark.c: copyright notices
+
+ * gtk/gtktextmarkprivate.h: reformat, and put _ in front of
+ internal functions
+
+ * gtk/gtktextchild.c (_pixbuf_segment_new): put _ in front of
+ internal function
+
+ * gtk/gtktextlayout.c (gtk_text_layout_get_line_display):
+ Reformatting
+
2000-09-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextbtree.c (gtk_text_btree_get_selection_bounds): Handle
+2000-10-02 Havoc Pennington <hp@pobox.com>
+
+ * gtk/gtktextview.c: text_window_* weren't static and should have
+ been.
+ Start work on child widgets; not yet complete, syncing to
+ office computer.
+
+ * gtk/gtktextchild.h: change this to contain a public interface,
+ starting work on child interfaces.
+ * gtk/gtktextchildprivate.h: move private interfaces here
+
+ * gtk/Makefile.am: update to reflect gtktextchildprivate.h
+
+ * gtk/gtktextview.h, gtk/gtktextview.c, gtk/gtktextbuffer.h,
+ gtk/gtktextbuffer.c, gtk/gtktextiter.h, gtk/gtk/textiter.c,
+ gtk/gtktextmark.c: copyright notices
+
+ * gtk/gtktextmarkprivate.h: reformat, and put _ in front of
+ internal functions
+
+ * gtk/gtktextchild.c (_pixbuf_segment_new): put _ in front of
+ internal function
+
+ * gtk/gtktextlayout.c (gtk_text_layout_get_line_display):
+ Reformatting
+
2000-09-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextbtree.c (gtk_text_btree_get_selection_bounds): Handle
+2000-10-02 Havoc Pennington <hp@pobox.com>
+
+ * gtk/gtktextview.c: text_window_* weren't static and should have
+ been.
+ Start work on child widgets; not yet complete, syncing to
+ office computer.
+
+ * gtk/gtktextchild.h: change this to contain a public interface,
+ starting work on child interfaces.
+ * gtk/gtktextchildprivate.h: move private interfaces here
+
+ * gtk/Makefile.am: update to reflect gtktextchildprivate.h
+
+ * gtk/gtktextview.h, gtk/gtktextview.c, gtk/gtktextbuffer.h,
+ gtk/gtktextbuffer.c, gtk/gtktextiter.h, gtk/gtk/textiter.c,
+ gtk/gtktextmark.c: copyright notices
+
+ * gtk/gtktextmarkprivate.h: reformat, and put _ in front of
+ internal functions
+
+ * gtk/gtktextchild.c (_pixbuf_segment_new): put _ in front of
+ internal function
+
+ * gtk/gtktextlayout.c (gtk_text_layout_get_line_display):
+ Reformatting
+
2000-09-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextbtree.c (gtk_text_btree_get_selection_bounds): Handle
+2000-10-02 Havoc Pennington <hp@pobox.com>
+
+ * gtk/gtktextview.c: text_window_* weren't static and should have
+ been.
+ Start work on child widgets; not yet complete, syncing to
+ office computer.
+
+ * gtk/gtktextchild.h: change this to contain a public interface,
+ starting work on child interfaces.
+ * gtk/gtktextchildprivate.h: move private interfaces here
+
+ * gtk/Makefile.am: update to reflect gtktextchildprivate.h
+
+ * gtk/gtktextview.h, gtk/gtktextview.c, gtk/gtktextbuffer.h,
+ gtk/gtktextbuffer.c, gtk/gtktextiter.h, gtk/gtk/textiter.c,
+ gtk/gtktextmark.c: copyright notices
+
+ * gtk/gtktextmarkprivate.h: reformat, and put _ in front of
+ internal functions
+
+ * gtk/gtktextchild.c (_pixbuf_segment_new): put _ in front of
+ internal function
+
+ * gtk/gtktextlayout.c (gtk_text_layout_get_line_display):
+ Reformatting
+
2000-09-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextbtree.c (gtk_text_btree_get_selection_bounds): Handle
+2000-10-02 Havoc Pennington <hp@pobox.com>
+
+ * gtk/gtktextview.c: text_window_* weren't static and should have
+ been.
+ Start work on child widgets; not yet complete, syncing to
+ office computer.
+
+ * gtk/gtktextchild.h: change this to contain a public interface,
+ starting work on child interfaces.
+ * gtk/gtktextchildprivate.h: move private interfaces here
+
+ * gtk/Makefile.am: update to reflect gtktextchildprivate.h
+
+ * gtk/gtktextview.h, gtk/gtktextview.c, gtk/gtktextbuffer.h,
+ gtk/gtktextbuffer.c, gtk/gtktextiter.h, gtk/gtk/textiter.c,
+ gtk/gtktextmark.c: copyright notices
+
+ * gtk/gtktextmarkprivate.h: reformat, and put _ in front of
+ internal functions
+
+ * gtk/gtktextchild.c (_pixbuf_segment_new): put _ in front of
+ internal function
+
+ * gtk/gtktextlayout.c (gtk_text_layout_get_line_display):
+ Reformatting
+
2000-09-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextbtree.c (gtk_text_btree_get_selection_bounds): Handle
+2000-10-02 Havoc Pennington <hp@pobox.com>
+
+ * gtk/gtktextview.c: text_window_* weren't static and should have
+ been.
+ Start work on child widgets; not yet complete, syncing to
+ office computer.
+
+ * gtk/gtktextchild.h: change this to contain a public interface,
+ starting work on child interfaces.
+ * gtk/gtktextchildprivate.h: move private interfaces here
+
+ * gtk/Makefile.am: update to reflect gtktextchildprivate.h
+
+ * gtk/gtktextview.h, gtk/gtktextview.c, gtk/gtktextbuffer.h,
+ gtk/gtktextbuffer.c, gtk/gtktextiter.h, gtk/gtk/textiter.c,
+ gtk/gtktextmark.c: copyright notices
+
+ * gtk/gtktextmarkprivate.h: reformat, and put _ in front of
+ internal functions
+
+ * gtk/gtktextchild.c (_pixbuf_segment_new): put _ in front of
+ internal function
+
+ * gtk/gtktextlayout.c (gtk_text_layout_get_line_display):
+ Reformatting
+
2000-09-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextbtree.c (gtk_text_btree_get_selection_bounds): Handle
+2000-10-02 Havoc Pennington <hp@pobox.com>
+
+ * gtk/gtktextview.c: text_window_* weren't static and should have
+ been.
+ Start work on child widgets; not yet complete, syncing to
+ office computer.
+
+ * gtk/gtktextchild.h: change this to contain a public interface,
+ starting work on child interfaces.
+ * gtk/gtktextchildprivate.h: move private interfaces here
+
+ * gtk/Makefile.am: update to reflect gtktextchildprivate.h
+
+ * gtk/gtktextview.h, gtk/gtktextview.c, gtk/gtktextbuffer.h,
+ gtk/gtktextbuffer.c, gtk/gtktextiter.h, gtk/gtk/textiter.c,
+ gtk/gtktextmark.c: copyright notices
+
+ * gtk/gtktextmarkprivate.h: reformat, and put _ in front of
+ internal functions
+
+ * gtk/gtktextchild.c (_pixbuf_segment_new): put _ in front of
+ internal function
+
+ * gtk/gtktextlayout.c (gtk_text_layout_get_line_display):
+ Reformatting
+
2000-09-30 Havoc Pennington <hp@pobox.com>
* gtk/gtktextbtree.c (gtk_text_btree_get_selection_bounds): Handle
gtktable.h \
gtktearoffmenuitem.h \
gtktextbuffer.h \
+ gtktextchild.h \
gtktextiter.h \
gtktextmark.h \
gtktexttag.h \
# GTK+ header files that don't get installed
gtk_private_h_sources = @STRIP_BEGIN@ \
gtktextbtree.h \
- gtktextchild.h \
+ gtktextchildprivate.h \
gtktextsegment.h \
gtktexttypes.h \
gtktextiterprivate.h \
tree->selection_bound_mark->body.mark.not_deleteable = TRUE;
- mark_segment_ref(tree->insert_mark);
- mark_segment_ref(tree->selection_bound_mark);
+ _mark_segment_ref(tree->insert_mark);
+ _mark_segment_ref(tree->selection_bound_mark);
}
tree->refcount = 1;
}
static void
-mark_destroy_foreach(gpointer key, gpointer value, gpointer user_data)
+mark_destroy_foreach (gpointer key, gpointer value, gpointer user_data)
{
- mark_segment_unref(value);
+ _mark_segment_unref (value);
}
void
NULL);
g_hash_table_destroy(tree->mark_table);
- mark_segment_unref(tree->insert_mark);
- mark_segment_unref(tree->selection_bound_mark);
+ _mark_segment_unref(tree->insert_mark);
+ _mark_segment_unref(tree->selection_bound_mark);
gtk_signal_disconnect(GTK_OBJECT(tree->table),
tree->tag_changed_handler);
tree = gtk_text_iter_get_btree(iter);
start_byte_offset = gtk_text_iter_get_line_index(iter);
- seg = gtk_text_pixbuf_segment_new (pixbuf);
+ seg = _pixbuf_segment_new (pixbuf);
prevPtr = gtk_text_line_segment_split(iter);
if (prevPtr == NULL)
}
else
{
- mark = mark_segment_new(tree,
- left_gravity,
- name);
+ mark = _mark_segment_new (tree,
+ left_gravity,
+ name);
mark->body.mark.line = gtk_text_iter_get_text_line(&iter);
if (segment->body.mark.name)
g_hash_table_remove (tree->mark_table, segment->body.mark.name);
- mark_segment_unref (segment);
+ _mark_segment_unref (segment);
segment->body.mark.tree = NULL;
segment->body.mark.line = NULL;
-/* gtktextbuffer.c - the "model" in the MVC text widget architecture
- * Copyright (c) 2000 Red Hat, Inc.
- * Developed by Havoc Pennington
+/* GTK - The GIMP Toolkit
+ * gtktextbuffer.c Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+
#include <string.h>
#include "gtkclipboard.h"
return gtk_text_buffer_get_mark (buffer, "selection_bound");
}
+
+GtkTextChildAnchor*
+gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer,
+ const GtkTextIter *where)
+{
+
+
+}
+
+void
+gtk_text_buffer_move_child_anchor (GtkTextBuffer *buffer,
+ GtkTextChildAnchor *anchor,
+ GtkTextIter *where)
+{
+
+
+}
+
+void
+gtk_text_buffer_delete_child_anchor (GtkTextBuffer *buffer,
+ GtkTextChildAnchor *anchor)
+{
+
+
+
+}
+
+void
+gtk_text_buffer_get_iter_at_child_anchor (GtkTextBuffer *buffer,
+ GtkTextIter *iter,
+ GtkTextChildAnchor *anchor)
+{
+
+
+}
+
/**
* gtk_text_buffer_place_cursor:
* @buffer: a #GtkTextBuffer
+/* GTK - The GIMP Toolkit
+ * gtktextbuffer.h Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
#ifndef GTK_TEXT_BUFFER_H
#define GTK_TEXT_BUFFER_H
#include <gtk/gtktexttagtable.h>
#include <gtk/gtktextiter.h>
#include <gtk/gtktextmark.h>
+#include <gtk/gtktextchild.h>
#ifdef __cplusplus
extern "C" {
GtkTextMark* gtk_text_buffer_get_insert (GtkTextBuffer *buffer);
GtkTextMark* gtk_text_buffer_get_selection_bound (GtkTextBuffer *buffer);
+/* Child widget anchors */
+
+GtkTextChildAnchor* gtk_text_buffer_create_child_anchor (GtkTextBuffer *buffer,
+ const GtkTextIter *where);
+void gtk_text_buffer_move_child_anchor (GtkTextBuffer *buffer,
+ GtkTextChildAnchor *anchor,
+ GtkTextIter *where);
+void gtk_text_buffer_delete_child_anchor (GtkTextBuffer *buffer,
+ GtkTextChildAnchor *anchor);
+
/* efficiently move insert and selection_bound to same location */
void gtk_text_buffer_place_cursor (GtkTextBuffer *buffer,
GtkTextIter *iter,
GtkTextMark *mark);
-
+void gtk_text_buffer_get_iter_at_child_anchor (GtkTextBuffer *buffer,
+ GtkTextIter *iter,
+ GtkTextChildAnchor *anchor);
/* There's no get_first_iter because you just get the iter for
line or char 0 */
/* gtktextchild.c - child pixmaps and widgets
- *
*
* Copyright (c) 1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
GtkTextLineSegmentClass gtk_text_pixbuf_type = {
"pixbuf", /* name */
- 0, /* leftGravity */
+ FALSE, /* leftGravity */
NULL, /* splitFunc */
pixbuf_segment_delete_func, /* deleteFunc */
pixbuf_segment_cleanup_func, /* cleanupFunc */
};
-#if 0
-GtkTextLineSegmentClass gtk_text_view_child_type = {
- "child-widget", /* name */
- 0, /* leftGravity */
- child_segment_split_func, /* splitFunc */
- child_segment_delete_func, /* deleteFunc */
- child_segment_cleanup_func, /* cleanupFunc */
- NULL, /* lineChangeFunc */
- child_segment_check_func /* checkFunc */
-};
-#endif
-
#define PIXBUF_SEG_SIZE ((unsigned) (G_STRUCT_OFFSET(GtkTextLineSegment, body) \
+ sizeof(GtkTextPixbuf)))
GtkTextLineSegment *
-gtk_text_pixbuf_segment_new (GdkPixbuf *pixbuf)
+_pixbuf_segment_new (GdkPixbuf *pixbuf)
{
GtkTextLineSegment *seg;
- seg = g_malloc(PIXBUF_SEG_SIZE);
+ seg = g_malloc (PIXBUF_SEG_SIZE);
seg->type = >k_text_pixbuf_type;
return seg;
}
+
+
+static GtkTextLineSegment *
+child_segment_cleanup_func (GtkTextLineSegment *seg,
+ GtkTextLine *line)
+{
+ seg->body.child.line = line;
+
+ return seg;
+}
+
+static int
+child_segment_delete_func (GtkTextLineSegment *seg,
+ GtkTextLine *line,
+ gboolean tree_gone)
+{
+ _widget_segment_unref (seg);
+
+ return 0;
+}
+
+static void
+child_segment_check_func (GtkTextLineSegment *seg,
+ GtkTextLine *line)
+{
+ if (seg->next == NULL)
+ g_error("child segment is the last segment in a line");
+
+ if (seg->byte_count != 3)
+ g_error("child segment has byte count of %d", seg->byte_count);
+
+ if (seg->char_count != 1)
+ g_error("child segment has char count of %d", seg->char_count);
+}
+
+GtkTextLineSegmentClass gtk_text_child_type = {
+ "child-widget", /* name */
+ FALSE, /* leftGravity */
+ NULL, /* splitFunc */
+ child_segment_delete_func, /* deleteFunc */
+ child_segment_cleanup_func, /* cleanupFunc */
+ NULL, /* lineChangeFunc */
+ child_segment_check_func /* checkFunc */
+};
+
+#define WIDGET_SEG_SIZE ((unsigned) (G_STRUCT_OFFSET (GtkTextLineSegment, body) \
+ + sizeof(GtkTextChildBody)))
+
+GtkTextLineSegment *
+_widget_segment_new (void)
+{
+ GtkTextLineSegment *seg;
+
+ seg = g_malloc (WIDGET_SEG_SIZE);
+
+ seg->type = >k_text_child_type;
+
+ seg->next = NULL;
+
+ seg->byte_count = 3; /* We convert to the 0xFFFD "unknown character",
+ * a 3-byte sequence in UTF-8
+ */
+ seg->char_count = 1;
+
+ seg->body.child.ref_count = 1;
+ seg->body.child.widgets = NULL;
+ seg->body.child.tree = NULL;
+ seg->body.child.line = NULL;
+
+ return seg;
+}
+
+void
+_widget_segment_add (GtkTextLineSegment *widget_segment,
+ GtkWidget *child)
+{
+ g_assert (widget_segment->type = >k_text_child_type);
+
+ widget_segment->body.child.widgets =
+ g_slist_prepend (widget_segment->body.child.widgets,
+ child);
+
+ g_object_ref (G_OBJECT (child));
+}
+
+void
+_widget_segment_remove (GtkTextLineSegment *widget_segment,
+ GtkWidget *child)
+{
+ g_assert (widget_segment->type = >k_text_child_type);
+
+ widget_segment->body.child.widgets =
+ g_slist_remove (widget_segment->body.child.widgets,
+ child);
+
+ g_object_unref (G_OBJECT (child));
+}
+
+void
+_widget_segment_ref (GtkTextLineSegment *widget_segment)
+{
+ g_assert (widget_segment->type = >k_text_child_type);
+
+ widget_segment->body.child.ref_count += 1;
+}
+
+void
+_widget_segment_unref (GtkTextLineSegment *widget_segment)
+{
+ g_assert (widget_segment->type = >k_text_child_type);
+
+ widget_segment->body.child.ref_count -= 1;
+
+ if (widget_segment->body.child.ref_count == 0)
+ {
+ GSList *tmp_list;
+
+ if (widget_segment->body.child.tree == NULL)
+ g_warning ("widget segment destroyed while still in btree");
+
+ tmp_list = widget_segment->body.child.widgets;
+ while (tmp_list)
+ {
+ g_object_unref (G_OBJECT (tmp_list->data));
+
+ tmp_list = g_slist_next (tmp_list);
+ }
+
+ g_slist_free (widget_segment->body.child.widgets);
+
+ g_free (widget_segment);
+ }
+}
+
+void
+gtk_text_child_anchor_ref (GtkTextChildAnchor *anchor)
+{
+ GtkTextLineSegment *seg = (GtkTextLineSegment *) anchor;
+
+ g_return_if_fail (seg->type = >k_text_child_type);
+ g_return_if_fail (seg->body.child.ref_count > 0);
+
+ _widget_segment_ref (seg);
+}
+
+void
+gtk_text_child_anchor_unref (GtkTextChildAnchor *anchor)
+{
+ GtkTextLineSegment *seg = (GtkTextLineSegment *) anchor;
+
+ g_return_if_fail (seg->type = >k_text_child_type);
+ g_return_if_fail (seg->body.child.ref_count > 0);
+
+ _widget_segment_unref (seg);
+}
+
+GList*
+gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor)
+{
+ GtkTextLineSegment *seg = (GtkTextLineSegment *) anchor;
+ GList *list = NULL;
+ GSList *iter;
+
+ g_return_val_if_fail (seg->type = >k_text_child_type, NULL);
+
+ iter = seg->body.child.widgets;
+ while (iter != NULL)
+ {
+ list = g_list_prepend (list, iter->data);
+
+ iter = g_slist_next (iter);
+ }
+
+ /* Order is not relevant, so we don't need to reverse the list
+ * again.
+ */
+ return list;
+}
+
+gboolean
+gtk_text_child_anchor_get_deleted (GtkTextChildAnchor *anchor)
+{
+ GtkTextLineSegment *seg = (GtkTextLineSegment *) anchor;
+
+ g_return_val_if_fail (seg->type = >k_text_child_type, TRUE);
+
+ return seg->body.child.tree == NULL;
+}
+
+
+
+/* GTK - The GIMP Toolkit
+ * gtktextchild.h Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
#ifndef GTK_TEXT_CHILD_H
#define GTK_TEXT_CHILD_H
-#include <gtk/gtktexttypes.h>
+#include <glib.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-typedef struct _GtkTextPixbuf GtkTextPixbuf;
-
-struct _GtkTextPixbuf {
- GdkPixbuf *pixbuf;
-};
+/* A GtkTextChildAnchor is a spot in the buffer where child widgets
+ * can be "anchored" (inserted inline, as if they were characters).
+ * The anchor can have multiple widgets anchored, to allow for multiple
+ * views.
+ */
-GtkTextLineSegment *gtk_text_pixbuf_segment_new(GdkPixbuf *pixbuf);
+typedef struct _GtkTextChildAnchor GtkTextChildAnchor;
+void gtk_text_child_anchor_ref (GtkTextChildAnchor *anchor);
+void gtk_text_child_anchor_unref (GtkTextChildAnchor *anchor);
+GList* gtk_text_child_anchor_get_widgets (GtkTextChildAnchor *anchor);
+gboolean gtk_text_child_anchor_get_deleted (GtkTextChildAnchor *anchor);
#ifdef __cplusplus
}
--- /dev/null
+/* gtktextchild.c - child pixmaps and widgets
+ *
+ * Copyright (c) 1994 The Regents of the University of California.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 2000 Red Hat, Inc.
+ * Tk -> Gtk port by Havoc Pennington <hp@redhat.com>
+ *
+ * This software is copyrighted by the Regents of the University of
+ * California, Sun Microsystems, Inc., and other parties. The
+ * following terms apply to all files associated with the software
+ * unless explicitly disclaimed in individual files.
+ *
+ * The authors hereby grant permission to use, copy, modify,
+ * distribute, and license this software and its documentation for any
+ * purpose, provided that existing copyright notices are retained in
+ * all copies and that this notice is included verbatim in any
+ * distributions. No written agreement, license, or royalty fee is
+ * required for any of the authorized uses. Modifications to this
+ * software may be copyrighted by their authors and need not follow
+ * the licensing terms described here, provided that the new terms are
+ * clearly indicated on the first page of each file where they apply.
+ *
+ * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
+ * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+ * NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
+ * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
+ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * GOVERNMENT USE: If you are acquiring this software on behalf of the
+ * U.S. government, the Government shall have only "Restricted Rights"
+ * in the software and related documentation as defined in the Federal
+ * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+ * are acquiring the software on behalf of the Department of Defense,
+ * the software shall be classified as "Commercial Computer Software"
+ * and the Government shall have only "Restricted Rights" as defined
+ * in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
+ * foregoing, the authors grant the U.S. Government and others acting
+ * in its behalf permission to use and distribute the software in
+ * accordance with the terms specified in this license.
+ *
+ */
+
+#ifndef GTK_TEXT_CHILD_PRIVATE_H
+#define GTK_TEXT_CHILD_PRIVATE_H
+
+#include <gtk/gtktexttypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef struct _GtkTextPixbuf GtkTextPixbuf;
+
+struct _GtkTextPixbuf
+{
+ GdkPixbuf *pixbuf;
+};
+
+GtkTextLineSegment *_pixbuf_segment_new (GdkPixbuf *pixbuf);
+
+typedef struct _GtkTextChildBody GtkTextChildBody;
+
+struct _GtkTextChildBody
+{
+ guint ref_count;
+ GSList *widgets;
+ GtkTextBTree *tree;
+ GtkTextLine *line;
+};
+
+GtkTextLineSegment *_widget_segment_new (void);
+void _widget_segment_add (GtkTextLineSegment *widget_segment,
+ GtkWidget *child);
+void _widget_segment_remove (GtkTextLineSegment *widget_segment,
+ GtkWidget *child);
+void _widget_segment_ref (GtkTextLineSegment *widget_segment);
+void _widget_segment_unref (GtkTextLineSegment *widget_segment);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+/* GTK - The GIMP Toolkit
+ * gtktextiter.c Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
#include "gtktextiter.h"
#include "gtktextbtree.h"
#include "gtktextiterprivate.h"
g_return_if_fail(iter != NULL);
if (real->chars_changed_stamp != gtk_text_btree_get_chars_changed_stamp(real->tree))
- g_print(" %20s: <invalidated iterator>\n", desc);
+ g_print (" %20s: <invalidated iterator>\n", desc);
else
{
check_invariants(iter);
- g_print(" %20s: line %d / char %d / line char %d / line byte %d\n",
- desc,
- gtk_text_iter_get_line(iter),
- gtk_text_iter_get_offset(iter),
- gtk_text_iter_get_line_offset(iter),
- gtk_text_iter_get_line_index(iter));
+ g_print (" %20s: line %d / char %d / line char %d / line byte %d\n",
+ desc,
+ gtk_text_iter_get_line(iter),
+ gtk_text_iter_get_offset(iter),
+ gtk_text_iter_get_line_offset(iter),
+ gtk_text_iter_get_line_index(iter));
check_invariants(iter);
}
}
void
-gtk_text_iter_check(const GtkTextIter *iter)
+gtk_text_iter_check (const GtkTextIter *iter)
{
const GtkTextRealIter *real = (const GtkTextRealIter*)iter;
gint line_char_offset, line_byte_offset, seg_char_offset, seg_byte_offset;
+/* GTK - The GIMP Toolkit
+ * gtktextiter.h Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
#ifndef GTK_TEXT_ITER_H
#define GTK_TEXT_ITER_H
{
if (seg->type == >k_text_char_type)
{
- /* We don't want to split segments because of marks, so we scan forward
- * for more segments only separated from us by marks. In theory, we
- * should also merge segments with identical styles, even if there
- * are toggles in-between
- */
+ /* We don't want to split segments because of marks,
+ * so we scan forward for more segments only
+ * separated from us by marks. In theory, we should
+ * also merge segments with identical styles, even
+ * if there are toggles in-between
+ */
gint byte_count = 0;
seg = seg->next;
}
- add_text_attrs (layout, style, byte_count, attrs, byte_offset - byte_count, size_only);
+ add_text_attrs (layout, style, byte_count, attrs,
+ byte_offset - byte_count, size_only);
}
else
{
- add_pixbuf_attrs (layout, display, style, seg, attrs, byte_offset);
- memcpy (text + byte_offset, gtk_text_unknown_char_utf8, seg->byte_count);
+ add_pixbuf_attrs (layout, display, style,
+ seg, attrs, byte_offset);
+ memcpy (text + byte_offset, gtk_text_unknown_char_utf8,
+ seg->byte_count);
byte_offset += seg->byte_count;
}
}
if (seg->body.mark.visible)
{
- cursor_byte_offsets = g_slist_prepend (cursor_byte_offsets, GINT_TO_POINTER (byte_offset));
+ cursor_byte_offsets = g_slist_prepend (cursor_byte_offsets,
+ GINT_TO_POINTER (byte_offset));
cursor_segs = g_slist_prepend (cursor_segs, seg);
}
}
-/*
- * tkTextMark.c --
- *
- * This file contains the procedure that implement marks for
- * text widgets.
- *
+/* gtktextmark.c - mark segments
+ *
* Copyright (c) 1994 The Regents of the University of California.
* Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 2000 Red Hat, Inc.
+ * Tk -> Gtk port by Havoc Pennington <hp@redhat.com>
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * This software is copyrighted by the Regents of the University of
+ * California, Sun Microsystems, Inc., and other parties. The
+ * following terms apply to all files associated with the software
+ * unless explicitly disclaimed in individual files.
+ *
+ * The authors hereby grant permission to use, copy, modify,
+ * distribute, and license this software and its documentation for any
+ * purpose, provided that existing copyright notices are retained in
+ * all copies and that this notice is included verbatim in any
+ * distributions. No written agreement, license, or royalty fee is
+ * required for any of the authorized uses. Modifications to this
+ * software may be copyrighted by their authors and need not follow
+ * the licensing terms described here, provided that the new terms are
+ * clearly indicated on the first page of each file where they apply.
+ *
+ * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
+ * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+ * NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
+ * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
+ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
- * RCS: @(#) $Id$
+ * GOVERNMENT USE: If you are acquiring this software on behalf of the
+ * U.S. government, the Government shall have only "Restricted Rights"
+ * in the software and related documentation as defined in the Federal
+ * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+ * are acquiring the software on behalf of the Department of Defense,
+ * the software shall be classified as "Commercial Computer Software"
+ * and the Government shall have only "Restricted Rights" as defined
+ * in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
+ * foregoing, the authors grant the U.S. Government and others acting
+ * in its behalf permission to use and distribute the software in
+ * accordance with the terms specified in this license.
+ *
*/
+
#include "gtktextbtree.h"
gboolean
seg = (GtkTextLineSegment*)mark;
- mark_segment_ref (seg);
+ _mark_segment_ref (seg);
return mark;
}
seg = (GtkTextLineSegment*)mark;
- mark_segment_unref (seg);
+ _mark_segment_unref (seg);
}
gboolean
GtkTextLineSegment*
-mark_segment_new (GtkTextBTree *tree,
- gboolean left_gravity,
- const gchar *name)
+_mark_segment_new (GtkTextBTree *tree,
+ gboolean left_gravity,
+ const gchar *name)
{
GtkTextLineSegment *mark;
}
void
-mark_segment_ref(GtkTextLineSegment *mark)
+_mark_segment_ref (GtkTextLineSegment *mark)
{
g_return_if_fail (mark != NULL);
g_return_if_fail (mark->type == >k_text_right_mark_type ||
}
void
-mark_segment_unref(GtkTextLineSegment *mark)
+_mark_segment_unref (GtkTextLineSegment *mark)
{
g_return_if_fail (mark != NULL);
g_return_if_fail (mark->type == >k_text_right_mark_type ||
+/* gtktextmark.h - mark segments
+ *
+ * Copyright (c) 1994 The Regents of the University of California.
+ * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright (c) 2000 Red Hat, Inc.
+ * Tk -> Gtk port by Havoc Pennington <hp@redhat.com>
+ *
+ * This software is copyrighted by the Regents of the University of
+ * California, Sun Microsystems, Inc., and other parties. The
+ * following terms apply to all files associated with the software
+ * unless explicitly disclaimed in individual files.
+ *
+ * The authors hereby grant permission to use, copy, modify,
+ * distribute, and license this software and its documentation for any
+ * purpose, provided that existing copyright notices are retained in
+ * all copies and that this notice is included verbatim in any
+ * distributions. No written agreement, license, or royalty fee is
+ * required for any of the authorized uses. Modifications to this
+ * software may be copyrighted by their authors and need not follow
+ * the licensing terms described here, provided that the new terms are
+ * clearly indicated on the first page of each file where they apply.
+ *
+ * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+ * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
+ * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
+ * NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
+ * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
+ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * GOVERNMENT USE: If you are acquiring this software on behalf of the
+ * U.S. government, the Government shall have only "Restricted Rights"
+ * in the software and related documentation as defined in the Federal
+ * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
+ * are acquiring the software on behalf of the Department of Defense,
+ * the software shall be classified as "Commercial Computer Software"
+ * and the Government shall have only "Restricted Rights" as defined
+ * in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
+ * foregoing, the authors grant the U.S. Government and others acting
+ * in its behalf permission to use and distribute the software in
+ * accordance with the terms specified in this license.
+ *
+ */
+
#ifndef GTK_TEXT_MARK_H
#define GTK_TEXT_MARK_H
guint not_deleteable : 1;
};
-GtkTextLineSegment *mark_segment_new (GtkTextBTree *tree,
- gboolean left_gravity,
- const gchar *name);
-void mark_segment_ref (GtkTextLineSegment *mark);
-void mark_segment_unref (GtkTextLineSegment *mark);
+GtkTextLineSegment *_mark_segment_new (GtkTextBTree *tree,
+ gboolean left_gravity,
+ const gchar *name);
+void _mark_segment_ref (GtkTextLineSegment *mark);
+void _mark_segment_unref (GtkTextLineSegment *mark);
#ifdef __cplusplus
#include <gtk/gtktextiter.h>
#include <gtk/gtktextmarkprivate.h>
#include <gtk/gtktextchild.h>
+#include <gtk/gtktextchildprivate.h>
#ifdef __cplusplus
extern "C" {
GtkTextToggleBody toggle; /* Information about tag toggle. */
GtkTextMarkBody mark; /* Information about mark. */
GtkTextPixbuf pixbuf; /* Child pixbuf */
-#if 0
- GtkTextChild child; /* child widget */
-#endif
+ GtkTextChildBody child; /* Child widget */
} body;
};
-GtkTextLineSegment *gtk_text_line_segment_split(const GtkTextIter *iter);
-
-GtkTextLineSegment *char_segment_new(const gchar *text, guint len);
+GtkTextLineSegment *gtk_text_line_segment_split (const GtkTextIter *iter);
-GtkTextLineSegment *char_segment_new_from_two_strings(const gchar *text1, guint len1,
- const gchar *text2, guint len2);
+GtkTextLineSegment *char_segment_new (const gchar *text,
+ guint len);
+GtkTextLineSegment *char_segment_new_from_two_strings (const gchar *text1,
+ guint len1,
+ const gchar *text2,
+ guint len2);
+GtkTextLineSegment *toggle_segment_new (GtkTextTagInfo *info,
+ gboolean on);
-GtkTextLineSegment *toggle_segment_new(GtkTextTagInfo *info, gboolean on);
#ifdef __cplusplus
}
/* In gtktextchild.c */
extern GtkTextLineSegmentClass gtk_text_pixbuf_type;
-extern GtkTextLineSegmentClass gtk_text_view_child_type;
+extern GtkTextLineSegmentClass gtk_text_child_type;
/*
* UTF 8 Stubs
-/* gtktext.c - A "view" widget for the GtkTextBuffer object
- *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1996 Sun Microsystems, Inc.
- * Copyright (c) 1999 by Scriptics Corporation.
- * Copyright (c) 2000 Red Hat, Inc.
- * Tk -> Gtk port by Havoc Pennington <hp@redhat.com>
+/* GTK - The GIMP Toolkit
+ * gtktextview.c Copyright (C) 2000 Red Hat, Inc.
*
- * This software is copyrighted by the Regents of the University of
- * California, Sun Microsystems, Inc., and other parties. The
- * following terms apply to all files associated with the software
- * unless explicitly disclaimed in individual files.
- *
- * The authors hereby grant permission to use, copy, modify,
- * distribute, and license this software and its documentation for any
- * purpose, provided that existing copyright notices are retained in
- * all copies and that this notice is included verbatim in any
- * distributions. No written agreement, license, or royalty fee is
- * required for any of the authorized uses. Modifications to this
- * software may be copyrighted by their authors and need not follow
- * the licensing terms described here, provided that the new terms are
- * clearly indicated on the first page of each file where they apply.
- *
- * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY
- * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
- * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION,
- * OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
- * NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS,
- * AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
- * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * GOVERNMENT USE: If you are acquiring this software on behalf of the
- * U.S. government, the Government shall have only "Restricted Rights"
- * in the software and related documentation as defined in the Federal
- * Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you
- * are acquiring the software on behalf of the Department of Defense,
- * the software shall be classified as "Commercial Computer Software"
- * and the Government shall have only "Restricted Rights" as defined
- * in Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the
- * foregoing, the authors grant the U.S. Government and others acting
- * in its behalf permission to use and distribute the software in
- * accordance with the terms specified in this license.
- *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include <string.h>
static GtkAdjustment* get_hadjustment (GtkTextView *text_view);
static GtkAdjustment* get_vadjustment (GtkTextView *text_view);
+/* Container methods */
+static void gtk_text_view_add (GtkContainer *container,
+ GtkWidget *child);
+static void gtk_text_view_remove (GtkContainer *container,
+ GtkWidget *child);
+static void gtk_text_view_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data);
+
+/* FIXME probably need the focus methods. */
+
+typedef struct _GtkTextViewChild GtkTextViewChild;
+
+struct _GtkTextViewChild
+{
+ GtkWidget *widget;
+
+ GtkTextChildAnchor *anchor;
+
+ /* These are ignored if anchor != NULL */
+ GtkTextWindowType type;
+ gint x;
+ gint y;
+};
+
+static GtkTextViewChild* text_view_child_new_anchored (GtkWidget *child,
+ GtkTextChildAnchor *anchor);
+static GtkTextViewChild* text_view_child_new_window (GtkWidget *child,
+ GtkTextWindowType type,
+ gint x,
+ gint y);
+static void text_view_child_free (GtkTextViewChild *child);
+
+static void text_view_child_realize (GtkTextView *text_view,
+ GtkTextViewChild *child);
+static void text_view_child_unrealize (GtkTextViewChild *child);
+
struct _GtkTextWindow
{
GtkTextWindowType type;
GdkRectangle allocation;
};
-GtkTextWindow *text_window_new (GtkTextWindowType type,
- GtkWidget *widget,
- gint width_request,
- gint height_request);
-void text_window_free (GtkTextWindow *win);
-void text_window_realize (GtkTextWindow *win,
- GdkWindow *parent);
-void text_window_unrealize (GtkTextWindow *win);
-void text_window_size_allocate (GtkTextWindow *win,
- GdkRectangle *rect);
-void text_window_scroll (GtkTextWindow *win,
- gint dx,
- gint dy);
-void text_window_invalidate_rect (GtkTextWindow *win,
- GdkRectangle *rect);
-
-gint text_window_get_width (GtkTextWindow *win);
-gint text_window_get_height (GtkTextWindow *win);
-void text_window_get_allocation (GtkTextWindow *win,
- GdkRectangle *rect);
+static GtkTextWindow *text_window_new (GtkTextWindowType type,
+ GtkWidget *widget,
+ gint width_request,
+ gint height_request);
+static void text_window_free (GtkTextWindow *win);
+static void text_window_realize (GtkTextWindow *win,
+ GdkWindow *parent);
+static void text_window_unrealize (GtkTextWindow *win);
+static void text_window_size_allocate (GtkTextWindow *win,
+ GdkRectangle *rect);
+static void text_window_scroll (GtkTextWindow *win,
+ gint dx,
+ gint dy);
+static void text_window_invalidate_rect (GtkTextWindow *win,
+ GdkRectangle *rect);
+
+static gint text_window_get_width (GtkTextWindow *win);
+static gint text_window_get_height (GtkTextWindow *win);
+static void text_window_get_allocation (GtkTextWindow *win,
+ GdkRectangle *rect);
enum {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GtkBindingSet *binding_set;
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
widget_class->drag_drop = gtk_text_view_drag_drop;
widget_class->drag_data_received = gtk_text_view_drag_data_received;
+ container_class->add = gtk_text_view_add;
+ container_class->remove = gtk_text_view_remove;
+ container_class->forall = gtk_text_view_forall;
+
klass->move = gtk_text_view_move;
klass->set_anchor = gtk_text_view_set_anchor;
klass->insert = gtk_text_view_insert;
}
}
+/*
+ * Container
+ */
+
+static void
+gtk_text_view_add (GtkContainer *container,
+ GtkWidget *child)
+{
+ g_return_if_fail (GTK_IS_TEXT_VIEW (container));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ /* This is pretty random. */
+ gtk_text_view_add_child_in_window (GTK_TEXT_VIEW (container),
+ child,
+ GTK_TEXT_WINDOW_WIDGET,
+ 0, 0);
+}
+
+static void
+gtk_text_view_remove (GtkContainer *container,
+ GtkWidget *child)
+{
+ GSList *iter;
+ GtkTextView *text_view;
+ GtkTextViewChild *vc;
+
+ g_return_if_fail (GTK_IS_TEXT_VIEW (container));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (child->parent == (GtkWidget*) container);
+
+ text_view = GTK_TEXT_VIEW (container);
+
+ vc = NULL;
+ iter = text_view->children;
+
+ while (iter != NULL)
+ {
+ vc = iter->data;
+
+ if (vc->widget == child)
+ break;
+
+ iter = g_slist_next (iter);
+ }
+
+ g_assert (iter != NULL); /* be sure we had the child in the list */
+
+ text_view->children = g_slist_remove (text_view->children, vc);
+
+ gtk_widget_unparent (vc->widget);
+
+ text_view_child_free (vc);
+}
+
+static void
+gtk_text_view_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ GSList *iter;
+ GtkTextView *text_view;
+
+ g_return_if_fail (GTK_IS_TEXT_VIEW (container));
+ g_return_if_fail (callback != NULL);
+
+ text_view = GTK_TEXT_VIEW (container);
+
+ iter = text_view->children;
+
+ while (iter != NULL)
+ {
+ GtkTextViewChild *vc = iter->data;
+
+ (* callback) (vc->widget, callback_data);
+
+ iter = g_slist_next (iter);
+ }
+}
+
/*
* Blink!
*/
/* Child GdkWindows */
-GtkTextWindow*
+static GtkTextWindow*
text_window_new (GtkTextWindowType type,
GtkWidget *widget,
gint width_request,
return win;
}
-void
+static void
text_window_free (GtkTextWindow *win)
{
if (win->window)
g_free (win);
}
-void
+static void
text_window_realize (GtkTextWindow *win,
GdkWindow *parent)
{
win);
}
-void
+static void
text_window_unrealize (GtkTextWindow *win)
{
if (win->type == GTK_TEXT_WINDOW_TEXT)
win->bin_window = NULL;
}
-void
+static void
text_window_size_allocate (GtkTextWindow *win,
GdkRectangle *rect)
{
}
}
-void
+static void
text_window_scroll (GtkTextWindow *win,
gint dx,
gint dy)
}
}
-void
+static void
text_window_invalidate_rect (GtkTextWindow *win,
GdkRectangle *rect)
{
gdk_window_invalidate_rect (win->bin_window, rect, FALSE);
}
-gint
+static gint
text_window_get_width (GtkTextWindow *win)
{
return win->allocation.width;
}
-gint
+static gint
text_window_get_height (GtkTextWindow *win)
{
return win->allocation.height;
}
-void
+static void
text_window_get_allocation (GtkTextWindow *win,
GdkRectangle *rect)
{
gtk_widget_queue_resize (GTK_WIDGET (text_view));
}
+/*
+ * Child widgets
+ */
+
+static GtkTextViewChild*
+text_view_child_new_anchored (GtkWidget *child,
+ GtkTextChildAnchor *anchor)
+{
+ GtkTextViewChild *vc;
+
+ vc = g_new (GtkTextViewChild, 1);
+
+ vc->widget = child;
+ vc->anchor = anchor;
+
+ g_object_ref (G_OBJECT (vc->widget));
+ gtk_text_child_anchor_ref (vc->anchor);
+
+ gtk_object_set_data (GTK_OBJECT (child),
+ "gtk-text-view-child",
+ vc);
+
+ return vc;
+}
+
+static GtkTextViewChild*
+text_view_child_new_window (GtkWidget *child,
+ GtkTextWindowType type,
+ gint x,
+ gint y)
+{
+ GtkTextViewChild *vc;
+
+ vc = g_new (GtkTextViewChild, 1);
+
+ vc->widget = child;
+ vc->anchor = NULL;
+
+ g_object_ref (G_OBJECT (vc->widget));
+
+ vc->type = type;
+ vc->x = x;
+ vc->y = y;
+
+ return vc;
+}
+
+static void
+text_view_child_free (GtkTextViewChild *child)
+{
+
+ gtk_object_remove_data (GTK_OBJECT (child->widget),
+ "gtk-text-view-child");
+
+ g_object_unref (G_OBJECT (child->widget));
+ gtk_text_child_anchor_unref (child->anchor);
+
+ g_free (child);
+}
+
+static void
+text_view_child_realize (GtkTextView *text_view,
+ GtkTextViewChild *vc)
+{
+ if (vc->anchor)
+ gtk_widget_set_parent_window (vc->widget,
+ text_view->text_window->bin_window);
+ else
+ {
+ GdkWindow *window;
+ window = gtk_text_view_get_window (text_view,
+ vc->type);
+ gtk_widget_set_parent_window (vc->widget, window);
+ }
+
+ gtk_widget_realize (vc->widget);
+}
+
+static void
+text_view_child_unrealize (GtkTextViewChild *vc)
+{
+ gtk_widget_unrealize (vc->widget);
+}
+
+static void
+add_child (GtkTextView *text_view,
+ GtkTextViewChild *vc)
+{
+ text_view->children = g_slist_prepend (text_view->children,
+ vc);
+
+ gtk_widget_set_parent (vc->widget, GTK_WIDGET (text_view));
+
+ if (GTK_WIDGET_REALIZED (text_view))
+ text_view_child_realize (text_view, vc);
+
+ if (GTK_WIDGET_VISIBLE (text_view) && GTK_WIDGET_VISIBLE (vc->widget))
+ {
+ if (GTK_WIDGET_MAPPED (text_view))
+ gtk_widget_map (vc->widget);
+
+ gtk_widget_queue_resize (vc->widget);
+ }
+}
+
+void
+gtk_text_view_add_child_at_anchor (GtkTextView *text_view,
+ GtkWidget *child,
+ GtkTextChildAnchor *anchor)
+{
+ GtkTextViewChild *vc;
+
+ g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (anchor != NULL);
+ g_return_if_fail (child->parent == NULL);
+
+ vc = text_view_child_new_anchored (child, anchor);
+
+ add_child (text_view, vc);
+}
+
+void
+gtk_text_view_add_child_in_window (GtkTextView *text_view,
+ GtkWidget *child,
+ GtkTextWindowType which_window,
+ gint xpos,
+ gint ypos)
+{
+ GtkTextViewChild *vc;
+
+ g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (xpos >= 0);
+ g_return_if_fail (ypos >= 0);
+ g_return_if_fail (child->parent == NULL);
+
+ vc = text_view_child_new_window (child, which_window,
+ xpos, ypos);
+
+ add_child (text_view, vc);
+}
+
+void
+gtk_text_view_move_child (GtkTextView *text_view,
+ GtkWidget *child,
+ gint xpos,
+ gint ypos)
+{
+ GtkTextViewChild *vc;
+
+ g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+ g_return_if_fail (xpos >= 0);
+ g_return_if_fail (ypos >= 0);
+ g_return_if_fail (child->parent == (GtkWidget*) text_view);
+
+ vc = gtk_object_get_data (GTK_OBJECT (child),
+ "gtk-text-view-child");
+
+ g_assert (vc != NULL);
+
+ vc->x = xpos;
+ vc->y = ypos;
+
+ if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_VISIBLE (text_view))
+ gtk_widget_queue_resize (child);
+}
+
+
+/* GTK - The GIMP Toolkit
+ * gtktextview.h Copyright (C) 2000 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
+ * file for a list of people on the GTK+ Team. See the ChangeLog
+ * files for a list of changes. These files are distributed with
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ */
+
#ifndef GTK_TEXT_VIEW_H
#define GTK_TEXT_VIEW_H
gint drag_start_x;
gint drag_start_y;
+
+ GSList *children;
};
struct _GtkTextViewClass {
gint height);
+/* Adding child widgets */
+void gtk_text_view_add_child_at_anchor (GtkTextView *text_view,
+ GtkWidget *child,
+ GtkTextChildAnchor *anchor);
+
+void gtk_text_view_add_child_in_window (GtkTextView *text_view,
+ GtkWidget *child,
+ GtkTextWindowType which_window,
+ /* window coordinates */
+ gint xpos,
+ gint ypos);
+
+void gtk_text_view_move_child (GtkTextView *text_view,
+ GtkWidget *child,
+ /* window coordinates */
+ gint xpos,
+ gint ypos);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
g_error ("%d chars, expected 1", n);
run_tests (buffer);
+
+ g_print ("All tests passed.\n");
return 0;
}
gtk_text_buffer_get_bounds (buffer, &start, &end);
- /* Check that walking the tree via chars and via indexes produces
+ /* Check that walking the tree via chars and via iterators produces
* the same number of indexable locations.
*/
num_chars = gtk_text_buffer_get_char_count (buffer);
if (i != gtk_text_buffer_get_line_count (buffer))
g_error ("Counted %d lines, buffer has %d", i,
- gtk_text_buffer_get_line_count (buffer));
+ gtk_text_buffer_get_line_count (buffer));
}
g_error ("%d chars, expected 1", n);
run_tests (buffer);
+
+ g_print ("All tests passed.\n");
return 0;
}
gtk_text_buffer_get_bounds (buffer, &start, &end);
- /* Check that walking the tree via chars and via indexes produces
+ /* Check that walking the tree via chars and via iterators produces
* the same number of indexable locations.
*/
num_chars = gtk_text_buffer_get_char_count (buffer);
if (i != gtk_text_buffer_get_line_count (buffer))
g_error ("Counted %d lines, buffer has %d", i,
- gtk_text_buffer_get_line_count (buffer));
+ gtk_text_buffer_get_line_count (buffer));
}